package com.study.thread.demo;

import com.study.thread.demo.thread.ThreadaDemo;
import com.study.thread.demo.threadpool.IgnorePolicyDemo;
import com.study.thread.demo.threadpool.ThreadPoolDemo;

public class TestThreadPoolDemo {

    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();

        ThreadPoolDemo testThreadPoolDemo = new ThreadPoolDemo(1, 1000L, new IgnorePolicyDemo());
        testThreadPoolDemo.execute(new ThreadaDemo());

        testThreadPoolDemo.shutdown();
        while (true) {//等待所有任务都执行结束
            if (testThreadPoolDemo.isTerminated()) {//所有的子线程都结束了
                System.out.println("共耗时:" + (System.currentTimeMillis() - startTime) / 1000.0 + "s");
                break;
            }
        }
    }
}